package com.minimalist.lindi.mapper;

import com.minimalist.common.entity.lindi.po.LindiTradeApplicationCredit;
import com.minimalist.common.entity.lindi.vo.tradeapplicationcredit.LindiTradeApplicationCreditQueryVO;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryChain;
import com.mybatisflex.core.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 林地指标交易平台_交易申请征信 映射层。
 *
 * @author 11987
 * @since 2025-06-04
 */
@Mapper
public interface LindiTradeApplicationCreditMapper extends BaseMapper<LindiTradeApplicationCredit>{

    /**
     * 根据交易申请征信ID查询交易申请征信
     *
     * @param tradeApplicationCreditId 交易申请征信ID
     * @return 交易申请征信
     */
    default LindiTradeApplicationCredit selectTradeApplicationCreditByTradeApplicationCreditId(Long tradeApplicationCreditId){
        return QueryChain.of(this)
                .where(LindiTradeApplicationCredit::getCreditId)
                .eq(tradeApplicationCreditId)
                .one();
    }

    /**
     * 分页查询交易申请征信列表
     *
     * @param queryVO 查询条件
     * @return 分页结果
     */
    default Page<LindiTradeApplicationCredit> selectPageTradeApplicationCreditList(
            LindiTradeApplicationCreditQueryVO queryVO){
        return paginate(queryVO.getPageNum(), queryVO.getPageSize()
                , QueryWrapper.create());
    }

    /**
     * 根据交易申请ID查询交易申请付款凭证列表
     *
     * @param tradeApplicationId 交易申请ID
     * @return 交易申请付款凭证列表
     */
    default List<LindiTradeApplicationCredit>
    selectTradeApplicationCreditListByTradeApplicationId(
            Long tradeApplicationId){
        return selectListByQuery(QueryWrapper.create()
                .eq(LindiTradeApplicationCredit::getTradeApplicationId
                        , tradeApplicationId));
    }
}
